library(readr)
library(fpp2)
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
## ── Attaching packages ────────────────────────────────────────────── fpp2 2.5 ──
## ✔ ggplot2   4.0.0      ✔ fma       2.5   
## ✔ forecast  8.24.0     ✔ expsmooth 2.3
## 
TRANSIT <- read_csv("Downloads/TRANSIT.csv")
## Rows: 283 Columns: 2
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl  (1): TRANSIT
## date (1): DATE
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Transit_Raw <- TRANSIT$TRANSIT
Transit_ts <- ts(Transit_Raw, frequency = 12, start = c(2000,1))
plot(Transit_ts)

plot(TRANSIT$TRANSIT)

plot(Transit_ts)

#Looking at this time series chart, it is clear that there is seasonality in this transit data. Up until 2020, there seemed to be limited trend. 2020 drastically changed the transits and since then, there has been both seasonality as well as an upward recovery trend.
fivenum(Transit_Raw)
## [1] 171450.0 772501.5 824766.0 866163.5 993437.0
mean(Transit_Raw)
## [1] 779435.2
boxplot(Transit_ts)

#Looking at these numbers, it is clear that my data is skewed towards the left tail. Looking at the box plot, it is clear that there are many outliers below the bottom whisker. This is supported by the fact that the median is 824766 but the mean is 779435. These lower outliers are pulling the mean down 
decompose(Transit_ts)
## $x
##         Jan    Feb    Mar    Apr    May    Jun    Jul    Aug    Sep    Oct
## 2000 724934 756536 843730 757458 818246 793911 743746 787064 802516 851255
## 2001 800293 761213 846702 803744 850680 807301 785014 809941 768513 871470
## 2002 794010 756102 820151 824757 838274 772040 782849 781609 805016 877109
## 2003 778679 732135 820157 810703 799984 754298 767411 745756 807125 830771
## 2004 740829 750265 843276 803337 781133 784558 754430 772963 814446 845387
## 2005 756467 750973 842424 816425 806149 795101 753939 808031 858809 858662
## 2006 793138 761980 874469 806944 870445 827752 790273 840294 850328 907084
## 2007 838203 796569 934752 884098 993437 876764 860196 908061 903028 946754
## 2008 852130 835901 889940 908295 912568 884081 910651 890570 929094 971677
## 2009 827360 806287 897860 874039 856958 848878 843229 825429 875511 917949
## 2010 788830 746114 893899 869986 853057 842674 819152 844979 864777 888591
## 2011 793606 780318 907771 856803 880563 861412 824766 843294 891667 919419
## 2012 843287 859851 913814 869911 900348 851686 848905 893636 877531 924987
## 2013 864280 813159 888516 907515 908342 851490 868345 888314 900754 972814
## 2014 832033 812275 913232 920884 923901 874651 886186 887484 931357 986733
## 2015 818017 779983 907646 901828 871727 878666 890344 840937 897493 953141
## 2016 796025 832503 907384 871083 879877 867550 809114 864510 884140 889002
## 2017 802693 777821 886230 834677 875749 842737 790814 837928 844867 910849
## 2018 788672 766031 841125 829115 857964 822283 797080 833069 816289 921343
## 2019 773669 740735 832480 853038 861455 800261 822014 835988 846274 915445
## 2020 815015 788599 505660 171450 200586 256196 306701 318609 331020 351338
## 2021 292833 275803 348362 352403 374081 409969 423379 428647 463998 500798
## 2022 392741 427514 512795 507034 517434 522856 495785 533257 563825 583121
## 2023 525669 512739 593360 560127 609180 572834 532206                     
##         Nov    Dec
## 2000 816120 755040
## 2001 820117 756221
## 2002 788746 754257
## 2003 724971 758869
## 2004 797405 767658
## 2005 825130 760996
## 2006 851564 804029
## 2007 870712 808452
## 2008 839026 835899
## 2009 830535 815176
## 2010 837848 812769
## 2011 862730 839221
## 2012 863060 824694
## 2013 862788 837701
## 2014 841871 864282
## 2015 848427 850726
## 2016 839892 807517
## 2017 831770 773762
## 2018 812423 763255
## 2019 814066 791316
## 2020 311158 309585
## 2021 469267 450587
## 2022 549008 520241
## 2023              
## 
## $seasonal
##              Jan         Feb         Mar         Apr         May         Jun
## 2000 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2001 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2002 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2003 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2004 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2005 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2006 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2007 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2008 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2009 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2010 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2011 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2012 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2013 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2014 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2015 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2016 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2017 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2018 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2019 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2020 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2021 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2022 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2023 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
##              Jul         Aug         Sep         Oct         Nov         Dec
## 2000 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2001 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2002 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2003 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2004 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2005 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2006 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2007 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2008 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2009 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2010 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2011 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2012 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2013 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2014 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2015 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2016 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2017 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2018 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2019 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2020 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2021 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2022 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2023 -20385.6561                                                            
## 
## $trend
##           Jan      Feb      Mar      Apr      May      Jun      Jul      Aug
## 2000       NA       NA       NA       NA       NA       NA 790686.3 794021.1
## 2001 803859.0 806531.7 806068.1 805493.6 806502.5 806718.2 806505.6 806030.9
## 2002 801294.0 800023.2 800363.7 802119.6 801047.5 799658.5 798937.9 797300.5
## 2003 789818.6 787681.5 786275.5 784432.6 779844.5 777379.4 775994.5 775172.8
## 2004 777650.9 778243.6 779682.3 780596.3 784223.4 787607.7 788625.5 789306.6
## 2005 793298.5 794739.2 798048.9 800450.5 802158.8 803036.4 804286.8 806273.4
## 2006 818205.2 821063.4 822054.3 823718.5 826837.5 829732.0 833402.7 836721.6
## 2007 866863.0 872600.1 877619.6 881468.3 883919.1 884901.2 885665.8 887884.9
## 2008 883778.8 885152.3 885509.6 887634.1 887352.3 887175.7 887287.2 885021.2
## 2009 871215.7 865692.2 860745.4 856274.1 853681.6 852464.4 849995.5 845882.9
## 2010 840862.5 840673.9 841041.2 839370.8 838452.2 838656.6 838755.3 840379.5
## 2011 845949.7 846113.4 847163.6 849568.5 851889.8 854028.7 857200.9 862584.8
## 2012 869338.6 872442.0 873950.6 873593.6 873839.3 873247.8 873517.2 872446.4
## 2013 872986.2 873574.5 874320.4 877280.8 879262.2 879792.9 878991.2 877610.8
## 2014 884717.7 885426.5 886667.0 888522.1 888230.5 888466.5 888990.1 887060.6
## 2015 879821.6 878055.4 874704.9 871894.2 870767.8 870476.1 868994.9 870266.9
## 2016 866239.6 863837.2 864263.0 861034.2 858006.1 855850.1 854327.6 852327.0
## 2017 842077.7 840207.6 837463.6 836737.5 837309.4 835564.5 833573.9 832498.4
## 2018 824859.4 824918.0 823524.8 822771.3 822402.5 821158.5 820095.6 818416.5
## 2019 818130.3 819290.9 820661.9 821665.5 821488.2 822725.9 825617.8 829334.9
## 2020 625412.7 582383.9 539357.5 494384.1 449925.2 408898.5 367068.8 323944.8
## 2021 336683.4 346129.9 356255.6 368023.8 380839.2 393302.2 403340.1 413824.2
## 2022 471104.4 478480.1 486998.3 494587.9 501340.5 507565.3 516006.2 525096.0
## 2023 553113.0       NA       NA       NA       NA       NA       NA         
##           Sep      Oct      Nov      Dec
## 2000 794339.8 796392.2 799672.2 801581.6
## 2001 804711.6 804480.9 804839.5 802853.4
## 2002 796302.1 795716.7 793535.8 791201.1
## 2003 776891.5 777547.9 776455.5 776930.9
## 2004 789300.6 789810.4 791398.1 792879.7
## 2005 808067.2 809007.4 811291.3 815330.8
## 2006 840674.6 846401.2 854740.6 861907.4
## 2007 887656.6 886797.6 884436.3 881371.6
## 2008 884117.3 883020.0 879275.6 875491.7
## 2009 843210.6 842876.7 842545.3 842124.2
## 2010 842382.7 842411.4 843008.2 844935.0
## 2011 866150.5 866948.4 868319.0 868738.1
## 2012 869446.8 869959.6 871859.5 872184.4
## 2013 878603.7 880190.6 881396.0 883009.3
## 2014 885482.3 884455.6 881487.7 879481.0
## 2015 872444.3 871152.4 870210.9 870087.3
## 2016 849167.2 846768.8 845079.9 843874.0
## 2017 830127.8 828016.7 827043.9 825450.6
## 2018 817002.3 817638.9 818781.1 818009.0
## 2019 817711.7 775694.7 719759.0 669553.5
## 2020 296024.2 297009.8 311778.5 325414.6
## 2021 426996.9 440291.2 452707.2 463383.9
## 2022 532003.9 537573.0 543607.9 549513.1
## 2023                                    
## 
## $random
##                Jan           Feb           Mar           Apr           May
## 2000            NA            NA            NA            NA            NA
## 2001   23569.96222     438.48833    9253.12848      26.82355   29638.31219
## 2002   19852.00389    1835.94666  -11593.45485   24413.82355   22687.31219
## 2003   15996.37889   -9789.26167    2500.79515   28046.86522    5600.22886
## 2004   -9685.91278   17778.57166   32212.96181   24517.11522  -17629.64614
## 2005   -9695.57944    1990.94666   12994.37848   17750.99022  -10549.02114
## 2006    2068.79556  -13326.17834   21033.96181  -14998.05145   29068.27052
## 2007   -1524.07944  -30273.92834   25751.67015    4406.11522   94978.68719
## 2008   -4512.82944   -3494.09501  -26950.32985   22437.32355   10676.43719
## 2009  -16719.70444  -13648.01167    5733.87848   19541.36522  -11262.85448
## 2010  -24896.57944  -48802.72001   21477.00348   32391.69855      65.56219
## 2011  -25207.70444  -20038.17834   29226.67015    9010.94855   14134.02052
## 2012    1084.33722   33166.19666    8482.67015   -1906.13478   11969.43719
## 2013   18429.71222  -14658.30334  -17185.12152   32010.65689   14540.52052
## 2014  -25548.74611  -27394.30334   -4815.78819   34138.32355   21131.22886
## 2015  -34668.62111  -52315.17834    1560.33681   31710.19855  -13579.97948
## 2016  -43078.62111   14422.98833   11740.21181   11825.24022    7331.64552
## 2017  -12248.70444  -16629.38667   17385.62848    -284.09311   23900.35386
## 2018   -9051.45444  -13129.84501  -13780.57985    8120.11522   21022.31219
## 2019  -17325.37111  -32798.67834  -19562.62152   33148.94855   25427.56219
## 2020  216738.25389  251972.32166  -65078.24652 -321157.67645 -263878.39614
## 2021  -16714.45444  -24569.72001  -39274.32985  -13844.38478  -21297.43781
## 2022  -51227.45444   -5208.88667   -5584.03819   14222.57355    1554.22886
## 2023    -308.07944            NA            NA            NA            NA
##                Jun           Jul           Aug           Sep           Oct
## 2000            NA  -26554.63560   -6767.46531  -14616.70807  -15146.43814
## 2001   11525.15499   -1105.96894    4099.78469  -58991.49973   -3020.06314
## 2002  -16676.13667    4296.78106  -15501.79865  -14078.95807   11383.06186
## 2003  -12139.05334   11802.15606  -29227.17365    7440.58360  -16786.10480
## 2004    7892.65499  -13809.84394  -16153.92365    2352.54193  -14432.60480
## 2005    3006.94666  -29962.13560    1947.28469   27948.91693  -20354.56314
## 2006    8962.40499  -22744.05227    3762.03469  -13139.49973   -9326.35480
## 2007    2805.15499   -5084.13560   20365.74302   -7421.45807  -10052.81314
## 2008    7847.65499   43749.40606    5738.40969   22183.79193   18647.81186
## 2009    7355.98833   13619.15606  -20264.21531    9507.50027    5063.10353
## 2010   14959.73833     782.32273    4789.15969    -398.54140  -23829.56314
## 2011   18325.69666  -12049.21894  -19101.13198    2723.66693  -17538.60480
## 2012  -10619.42834   -4226.55227   21379.24302  -14708.70807  -14981.77147
## 2013  -17360.51167    9739.44773   10892.90969    -642.62473   22614.18686
## 2014   -2873.17834   17581.57273     613.07635   23081.79193   32268.22853
## 2015   19132.27999   41734.73940  -29140.25698    2255.79193   11979.43686
## 2016   22642.23833  -24827.92727   12372.65969   12179.95860  -27776.02147
## 2017   18114.82166  -22374.21894    5619.24302   -8053.66640   12823.14520
## 2018   12066.82166   -2629.96894   14842.15969  -23506.16640   33694.93686
## 2019  -11522.51167   16781.82273    6842.74302    5769.37527   69741.06186
## 2020 -141760.17834  -39982.17727   -5146.09031   12202.95860  -15680.97980
## 2021   27609.19666   40424.57273   15012.45135   14208.25027   -9502.39647
## 2022   26233.02999     164.40606    8350.70135    9028.25027  -24461.14647
## 2023            NA            NA                                          
##                Nov           Dec
## 2000   19052.98759  -16612.06857
## 2001   17882.73759  -16702.86024
## 2002   -2184.51241   -7014.56857
## 2003  -48879.30408   11867.59809
## 2004    8612.15425    4707.80643
## 2005   16443.90425  -24405.27691
## 2006    -571.34575  -27948.90191
## 2007  -11119.05408  -42990.11024
## 2008  -37644.34575   -9663.19357
## 2009   -9405.05408    2981.26476
## 2010   -2554.92908   -2236.48524
## 2011   -2983.72075     412.43143
## 2012   -6194.26241  -17560.90191
## 2013  -16002.72075  -15378.77691
## 2014  -37011.42908   14730.47309
## 2015  -19178.67908   10568.18143
## 2016   -2582.67908   -6427.52691
## 2017    7331.36259  -21759.06857
## 2018   -3752.88741  -24824.48524
## 2019   96912.19592  151692.05643
## 2020    1984.77925   14099.88976
## 2021   19165.02925   17132.63976
## 2022    8005.32092     657.43143
## 2023                            
## 
## $figure
##  [1] -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
##  [7] -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 
## $type
## [1] "additive"
## 
## attr(,"class")
## [1] "decomposed.ts"
plot(decompose(Transit_ts))

attributes((decompose(Transit_ts)))
## $names
## [1] "x"        "seasonal" "trend"    "random"   "figure"   "type"    
## 
## $class
## [1] "decomposed.ts"
stl_transit<-stl(Transit_ts,s.window = "periodic")
plot(stl_transit)

attributes(stl_transit)
## $names
## [1] "time.series" "weights"     "call"        "win"         "deg"        
## [6] "jump"        "inner"       "outer"      
## 
## $class
## [1] "stl"
attributes((decompose(Transit_ts)))
## $names
## [1] "x"        "seasonal" "trend"    "random"   "figure"   "type"    
## 
## $class
## [1] "decomposed.ts"
decomp_transit<-decompose(Transit_ts)
decomp_transit$seasonal
##              Jan         Feb         Mar         Apr         May         Jun
## 2000 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2001 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2002 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2003 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2004 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2005 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2006 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2007 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2008 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2009 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2010 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2011 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2012 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2013 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2014 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2015 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2016 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2017 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2018 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2019 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2020 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2021 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2022 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
## 2023 -27135.9622 -45757.1967  31380.7465  -1776.4486  14539.2295 -10942.3633
##              Jul         Aug         Sep         Oct         Nov         Dec
## 2000 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2001 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2002 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2003 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2004 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2005 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2006 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2007 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2008 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2009 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2010 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2011 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2012 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2013 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2014 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2015 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2016 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2017 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2018 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2019 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2020 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2021 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2022 -20385.6561   -189.6597  22792.8747  70009.1881  -2605.2376 -29929.5148
## 2023 -20385.6561
seasadj(stl_transit)
##           Jan      Feb      Mar      Apr      May      Jun      Jul      Aug
## 2000 753278.5 801529.0 811357.6 760753.0 802351.7 804104.2 765494.7 787285.0
## 2001 828637.5 806206.0 814329.6 807039.0 834785.7 817494.2 806762.7 810162.0
## 2002 822354.5 801095.0 787778.6 828052.0 822379.7 782233.2 804597.7 781830.0
## 2003 807023.5 777128.0 787784.6 813998.0 784089.7 764491.2 789159.7 745977.0
## 2004 769173.5 795258.0 810903.6 806632.0 765238.7 794751.2 776178.7 773184.0
## 2005 784811.5 795966.0 810051.6 819720.0 790254.7 805294.2 775687.7 808252.0
## 2006 821482.5 806973.0 842096.6 810239.0 854550.7 837945.2 812021.7 840515.0
## 2007 866547.5 841562.0 902379.6 887393.0 977542.7 886957.2 881944.7 908282.0
## 2008 880474.5 880894.0 857567.6 911590.0 896673.7 894274.2 932399.7 890791.0
## 2009 855704.5 851280.0 865487.6 877334.0 841063.7 859071.2 864977.7 825650.0
## 2010 817174.5 791107.0 861526.6 873281.0 837162.7 852867.2 840900.7 845200.0
## 2011 821950.5 825311.0 875398.6 860098.0 864668.7 871605.2 846514.7 843515.0
## 2012 871631.5 904844.0 881441.6 873206.0 884453.7 861879.2 870653.7 893857.0
## 2013 892624.5 858152.0 856143.6 910810.0 892447.7 861683.2 890093.7 888535.0
## 2014 860377.5 857268.0 880859.6 924179.0 908006.7 884844.2 907934.7 887705.0
## 2015 846361.5 824976.0 875273.6 905123.0 855832.7 888859.2 912092.7 841158.0
## 2016 824369.5 877496.0 875011.6 874378.0 863982.7 877743.2 830862.7 864731.0
## 2017 831037.5 822814.0 853857.6 837972.0 859854.7 852930.2 812562.7 838149.0
## 2018 817016.5 811024.0 808752.6 832410.0 842069.7 832476.2 818828.7 833290.0
## 2019 802013.5 785728.0 800107.6 856333.0 845560.7 810454.2 843762.7 836209.0
## 2020 843359.5 833592.0 473287.6 174745.0 184691.7 266389.2 328449.7 318830.0
## 2021 321177.5 320796.0 315989.6 355698.0 358186.7 420162.2 445127.7 428868.0
## 2022 421085.5 472507.0 480422.6 510329.0 501539.7 533049.2 517533.7 533478.0
## 2023 554013.5 557732.0 560987.6 563422.0 593285.7 583027.2 553954.7         
##           Sep      Oct      Nov      Dec
## 2000 779732.2 781205.4 818560.6 784904.2
## 2001 745729.2 801420.4 822557.6 786085.2
## 2002 782232.2 807059.4 791186.6 784121.2
## 2003 784341.2 760721.4 727411.6 788733.2
## 2004 791662.2 775337.4 799845.6 797522.2
## 2005 836025.2 788612.4 827570.6 790860.2
## 2006 827544.2 837034.4 854004.6 833893.2
## 2007 880244.2 876704.4 873152.6 838316.2
## 2008 906310.2 901627.4 841466.6 865763.2
## 2009 852727.2 847899.4 832975.6 845040.2
## 2010 841993.2 818541.4 840288.6 842633.2
## 2011 868883.2 849369.4 865170.6 869085.2
## 2012 854747.2 854937.4 865500.6 854558.2
## 2013 877970.2 902764.4 865228.6 867565.2
## 2014 908573.2 916683.4 844311.6 894146.2
## 2015 874709.2 883091.4 850867.6 880590.2
## 2016 861356.2 818952.4 842332.6 837381.2
## 2017 822083.2 840799.4 834210.6 803626.2
## 2018 793505.2 851293.4 814863.6 793119.2
## 2019 823490.2 845395.4 816506.6 821180.2
## 2020 308236.2 281288.4 313598.6 339449.2
## 2021 441214.2 430748.4 471707.6 480451.2
## 2022 541041.2 513071.4 551448.6 550105.2
## 2023
plot(seasadj(stl_transit))

#Looking at the seasonally adjusted data, seasonality plays a rather large role in influencing transit. This data is not only affected by seasonality, but the graph changes drastically after removing seasonality
#Looking at these charts and numbers, it is clear that my data does have seasonality. The decomposition charts show in the seasonality sector that this is present. Looking at the stability of my seasonality chart and the use of stl, I would say that my decomposition is additive. This is also confirmed in the decomp model. The time series is highest in October at around 70000 and lowest in February. Maybe people rely the most on public transportation in October there are not a lot of car sales and in February people got new cars. 
naive(Transit_ts)
##          Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## Aug 2023         532206 460690.8 603721.2 422832.9 641579.1
## Sep 2023         532206 431068.2 633343.8 377529.1 686882.9
## Oct 2023         532206 408338.0 656074.0 342766.3 721645.7
## Nov 2023         532206 389175.6 675236.4 313459.9 750952.1
## Dec 2023         532206 372293.2 692118.8 287640.4 776771.6
## Jan 2024         532206 357030.3 707381.7 264297.8 800114.2
## Feb 2024         532206 342994.6 721417.4 242832.1 821579.9
## Mar 2024         532206 329930.5 734481.5 222852.3 841559.7
## Apr 2024         532206 317660.4 746751.6 204086.8 860325.2
## May 2024         532206 306055.1 758356.9 186338.0 878074.0
plot(naive(Transit_ts))

accuracy(naive(Transit_ts))
##                     ME    RMSE      MAE        MPE     MAPE      MASE
## Training set -683.4326 55803.6 41483.85 -0.6755225 6.063339 0.7298063
##                    ACF1
## Training set -0.1325041
residuals(naive(Transit_ts))
##          Jan     Feb     Mar     Apr     May     Jun     Jul     Aug     Sep
## 2000      NA   31602   87194  -86272   60788  -24335  -50165   43318   15452
## 2001   45253  -39080   85489  -42958   46936  -43379  -22287   24927  -41428
## 2002   37789  -37908   64049    4606   13517  -66234   10809   -1240   23407
## 2003   24422  -46544   88022   -9454  -10719  -45686   13113  -21655   61369
## 2004  -18040    9436   93011  -39939  -22204    3425  -30128   18533   41483
## 2005  -11191   -5494   91451  -25999  -10276  -11048  -41162   54092   50778
## 2006   32142  -31158  112489  -67525   63501  -42693  -37479   50021   10034
## 2007   34174  -41634  138183  -50654  109339 -116673  -16568   47865   -5033
## 2008   43678  -16229   54039   18355    4273  -28487   26570  -20081   38524
## 2009   -8539  -21073   91573  -23821  -17081   -8080   -5649  -17800   50082
## 2010  -26346  -42716  147785  -23913  -16929  -10383  -23522   25827   19798
## 2011  -19163  -13288  127453  -50968   23760  -19151  -36646   18528   48373
## 2012    4066   16564   53963  -43903   30437  -48662   -2781   44731  -16105
## 2013   39586  -51121   75357   18999     827  -56852   16855   19969   12440
## 2014   -5668  -19758  100957    7652    3017  -49250   11535    1298   43873
## 2015  -46265  -38034  127663   -5818  -30101    6939   11678  -49407   56556
## 2016  -54701   36478   74881  -36301    8794  -12327  -58436   55396   19630
## 2017   -4824  -24872  108409  -51553   41072  -33012  -51923   47114    6939
## 2018   14910  -22641   75094  -12010   28849  -35681  -25203   35989  -16780
## 2019   10414  -32934   91745   20558    8417  -61194   21753   13974   10286
## 2020   23699  -26416 -282939 -334210   29136   55610   50505   11908   12411
## 2021  -16752  -17030   72559    4041   21678   35888   13410    5268   35351
## 2022  -57846   34773   85281   -5761   10400    5422  -27071   37472   30568
## 2023    5428  -12930   80621  -33233   49053  -36346  -40628                
##          Oct     Nov     Dec
## 2000   48739  -35135  -61080
## 2001  102957  -51353  -63896
## 2002   72093  -88363  -34489
## 2003   23646 -105800   33898
## 2004   30941  -47982  -29747
## 2005    -147  -33532  -64134
## 2006   56756  -55520  -47535
## 2007   43726  -76042  -62260
## 2008   42583 -132651   -3127
## 2009   42438  -87414  -15359
## 2010   23814  -50743  -25079
## 2011   27752  -56689  -23509
## 2012   47456  -61927  -38366
## 2013   72060 -110026  -25087
## 2014   55376 -144862   22411
## 2015   55648 -104714    2299
## 2016    4862  -49110  -32375
## 2017   65982  -79079  -58008
## 2018  105054 -108920  -49168
## 2019   69171 -101379  -22750
## 2020   20318  -40180   -1573
## 2021   36800  -31531  -18680
## 2022   19296  -34113  -28767
## 2023
plot(residuals(naive(Transit_ts)))

#This plot of residuals shows that the residuals are relatively stable, with the exception of covid. This model does not look good since the residuals look cyclic and large. 
hist(residuals(naive(Transit_ts)))

#This plot shows that my residuals are largely negative and concentrated between 1e05 and -1e05. The frequency overall is rather high, meaning this may not be the best model. 
naive_fit<-fitted.values(naive(Transit_ts))
naive_resid<-residuals(naive(Transit_ts))
plot(naive_fit,naive_resid)

#This chart shows large clusters in the right of the chart, indicating the model is missing some signals as my residuals increase as my models becomes more fitted. 
plot(Transit_ts,naive_resid)

#This plot shows a majority of the plots are located towards the right, meaning that as the actual values increase, there tends to be more residuals. This model does worse as the acutal values increase. 
Acf(naive_resid)

#This plot shows that many of the residuals are outside of the blue lines, indicating that this model is auto correlated and missed some important signals. This model did not predict the some of the outlier times well, meaning the model would show more accurate if we eliminated some time periods. 
accuracy(naive(Transit_ts))
##                     ME    RMSE      MAE        MPE     MAPE      MASE
## Training set -683.4326 55803.6 41483.85 -0.6755225 6.063339 0.7298063
##                    ACF1
## Training set -0.1325041
plot(accuracy(naive(Transit_ts)))

naive(Transit_ts,12)
##          Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## Aug 2023         532206 460690.8 603721.2 422832.9 641579.1
## Sep 2023         532206 431068.2 633343.8 377529.1 686882.9
## Oct 2023         532206 408338.0 656074.0 342766.3 721645.7
## Nov 2023         532206 389175.6 675236.4 313459.9 750952.1
## Dec 2023         532206 372293.2 692118.8 287640.4 776771.6
## Jan 2024         532206 357030.3 707381.7 264297.8 800114.2
## Feb 2024         532206 342994.6 721417.4 242832.1 821579.9
## Mar 2024         532206 329930.5 734481.5 222852.3 841559.7
## Apr 2024         532206 317660.4 746751.6 204086.8 860325.2
## May 2024         532206 306055.1 758356.9 186338.0 878074.0
## Jun 2024         532206 295016.9 769395.1 169456.6 894955.4
## Jul 2024         532206 284470.1 779941.9 153326.6 911085.4
plot(naive(Transit_ts,12))

#It hard to draw an real conclusion yet since I do not have a point of comparison, but the mape here is 6.06 for this model. This model predicts the value one year from now will be 532206. The nature of this model produces a flat forecast. This model overal did not do the best job since it does not capture the seasonality present. 
plot(Transit_ts)
lines(ma(Transit_ts,3),col="red")
lines(ma(Transit_ts,6),col="blue")
lines(ma(Transit_ts,9),col="green")

#Looking at these charts, the MA3 was the best. This is because it was the most responsive to the volatile changes in transportation. As the ma increased, the model became smoothed out and less responsive. 
ses(Transit_ts,12)
##          Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## Aug 2023       539578.3 468678.2 610478.5 431145.9 648010.7
## Sep 2023       539578.3 447103.9 632052.8 398150.9 681005.8
## Oct 2023       539578.3 429686.5 649470.1 371513.3 707643.4
## Nov 2023       539578.3 414674.8 664481.9 348554.8 730601.9
## Dec 2023       539578.3 401283.0 677873.6 328073.9 751082.8
## Jan 2024       539578.3 389078.2 690078.4 309408.3 769748.4
## Feb 2024       539578.3 377791.5 701365.1 292146.7 787009.9
## Mar 2024       539578.3 367242.4 711914.2 276013.3 803143.4
## Apr 2024       539578.3 357302.8 721853.8 260812.0 818344.6
## May 2024       539578.3 347877.9 731278.7 246397.9 832758.8
## Jun 2024       539578.3 338895.2 740261.5 232659.9 846496.8
## Jul 2024       539578.3 330297.6 748859.1 219511.1 859645.6
summary(ses(Transit_ts,12))
## 
## Forecast method: Simple exponential smoothing
## 
## Model Information:
## Simple exponential smoothing 
## 
## Call:
## ses(y = Transit_ts, h = 12)
## 
##   Smoothing parameters:
##     alpha = 0.8374 
## 
##   Initial states:
##     l = 732001.6666 
## 
##   sigma:  55323.68
## 
##      AIC     AICc      BIC 
## 7782.916 7783.002 7793.852 
## 
## Error measures:
##                     ME     RMSE      MAE        MPE     MAPE      MASE
## Training set -812.0035 55127.84 40313.36 -0.8363806 6.026904 0.7092143
##                    ACF1
## Training set 0.01607982
## 
## Forecasts:
##          Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## Aug 2023       539578.3 468678.2 610478.5 431145.9 648010.7
## Sep 2023       539578.3 447103.9 632052.8 398150.9 681005.8
## Oct 2023       539578.3 429686.5 649470.1 371513.3 707643.4
## Nov 2023       539578.3 414674.8 664481.9 348554.8 730601.9
## Dec 2023       539578.3 401283.0 677873.6 328073.9 751082.8
## Jan 2024       539578.3 389078.2 690078.4 309408.3 769748.4
## Feb 2024       539578.3 377791.5 701365.1 292146.7 787009.9
## Mar 2024       539578.3 367242.4 711914.2 276013.3 803143.4
## Apr 2024       539578.3 357302.8 721853.8 260812.0 818344.6
## May 2024       539578.3 347877.9 731278.7 246397.9 832758.8
## Jun 2024       539578.3 338895.2 740261.5 232659.9 846496.8
## Jul 2024       539578.3 330297.6 748859.1 219511.1 859645.6
#Alpha here is .8374. This represent the weight given to my recent data. The remainder, (1-.8374) is the weight given the historical data. The value of intial state is 732001. The value of sigma is 55323. This value represents the standard deviation, which is relatviely large here since our mean was around 79000. 
ses_resid<-residuals(ses(Transit_ts))
ses_resid
##                Jan           Feb           Mar           Apr           May
## 2000   -7067.66664   30452.53069   92146.73071  -71285.46416   49194.29336
## 2001   34614.16470  -33450.43055   80048.69764  -29939.06089   42066.77886
## 2002   26455.00224  -33605.41828   58583.49079   14133.88642   15815.70332
## 2003   16801.87805  -43811.38056   80896.61617    3702.84266  -10116.77805
## 2004  -15183.12841    6966.65034   94144.04025  -24627.62625  -26209.38142
## 2005  -17134.47941   -8280.71297   90104.24357  -11344.64964  -12121.06816
## 2006   20864.68426  -27764.61495  107973.42583  -49964.44626   55374.89548
## 2007   25230.53170  -37530.56340  132079.11406  -29172.95166  104594.37713
## 2008   31730.21001  -11068.47042   52238.84901   26851.00824    8639.98724
## 2009  -12348.05617  -23081.25992   87819.11610   -9538.29761  -18632.28715
## 2010  -30940.70134  -47748.12568  140019.35285   -1140.56918  -17114.49959
## 2011  -24465.23459  -17266.97041  124644.73899  -30696.06160   18767.66198
## 2012   -1102.31972   16384.72121   56627.77400  -34693.18693   24794.57855
## 2013   31905.99626  -45931.88094   67886.74278   30039.94628    5712.62891
## 2014  -12337.27722  -21764.50686   97417.26984   23495.72441    6838.29147
## 2015  -46182.73894  -45545.05620  120255.65508   13740.10772  -27866.33996
## 2016  -56823.32412   27236.38310   79310.66374  -23402.09305    4987.93652
## 2017  -11348.56932  -26717.70564  104063.69279  -34628.31640   35440.12895
## 2018    3677.01227  -22042.97904   71508.97975    -379.94129   28787.20721
## 2019     -19.88805  -32937.23455   86388.16268   34607.97537   14045.56283
## 2020   17623.99339  -23549.67358 -286769.06564 -380849.47215  -32804.49666
## 2021  -17972.10049  -19952.94177   69313.89868   15314.05569   24168.64338
## 2022  -61534.08818   24765.23509   89308.76182    8763.97500   11825.35307
## 2023     -44.74156  -12937.27667   78516.91059  -20463.18727   45724.91351
##                Jun           Jul           Aug           Sep           Oct
## 2000  -16334.15141  -52821.54944   34727.22268   21099.95694   52170.64927
## 2001  -36537.35424  -28229.35265   20335.84194  -38120.62467   96757.14783
## 2002  -63661.76979     455.19377   -1165.96832   23217.36955   75869.02047
## 2003  -47331.36990    5415.13307  -20774.29501   57990.31565   33077.41376
## 2004    -837.63451  -30264.23098   13610.89393   43696.64500   38047.72350
## 2005  -13019.34311  -43279.43651   47053.13035   58430.61468    9356.02300
## 2006  -33686.95226  -42957.76971   43034.44551   17033.02487   59526.21264
## 2007  -99662.00710  -32776.80340   42534.25484    1884.67499   44032.51928
## 2008  -27081.81202   22165.47535  -16476.05723   35844.37132   48412.64747
## 2009  -11110.31303   -7455.95618  -19012.61985   46989.83052   50080.31974
## 2010  -13166.46350  -25663.36384   21653.16856   23319.62235   27606.65063
## 2011  -16098.66991  -39264.25126   12142.15099   50347.77197   35940.44775
## 2012  -44629.46583  -10039.43537   43098.20894   -9095.60479   45976.71141
## 2013  -55922.91096    7759.82426   21231.04026   15892.96836   74644.79642
## 2014  -48137.83574    3705.97128    1900.73079   44182.13056   62561.68177
## 2015    2406.88150   12069.44976  -47444.05199   48839.80670   63591.19569
## 2016  -11515.77329  -60308.89932   45587.49704   27044.24740    9260.41522
## 2017  -27248.09759  -56354.56896   37948.62038   13110.87778   68114.32350
## 2018  -30999.11374  -30244.62574   31070.08248  -11726.83207  103146.77456
## 2019  -58909.66143   12172.06592   15953.63727   12880.66348   71265.88197
## 2020   50274.75087   58681.57176   21451.83809   15899.87842   22903.92026
## 2021   39818.73349   19886.02874    8502.21873   36733.78162   42774.29915
## 2022    7345.24867  -25876.38537   33263.52322   35977.90417   25147.36495
## 2023  -28909.40350  -45329.75999                                          
##                Nov           Dec
## 2000  -26650.08361  -65414.30932
## 2001  -35616.63634  -69688.60917
## 2002  -76023.83413  -46853.34441
## 2003 -100420.36425   17565.85911
## 2004  -41794.00432  -36544.28232
## 2005  -32010.35758  -69340.09215
## 2006  -45838.79143  -54990.11735
## 2007  -68880.65067  -73462.59321
## 2008 -124777.27653  -23420.49400
## 2009  -79269.05008  -28251.13900
## 2010  -46253.11679  -32601.50229
## 2011  -50843.72688  -31778.10873
## 2012  -54449.45166  -47221.53565
## 2013  -97885.93916  -41006.94772
## 2014 -134687.10959     505.79316
## 2015  -94371.67178  -13049.39523
## 2016  -47603.90702  -40117.19176
## 2017  -68001.04050  -69067.53541
## 2018  -92144.44191  -64154.16360
## 2019  -89788.47816  -37352.99498
## 2020  -36454.95822   -7501.95194
## 2021  -24574.28474  -22676.70608
## 2022  -30023.08945  -33649.88735
## 2023
plot(ses_resid)

#The plot of residuals shows that there may be some seasonality that may not be accounted for due to the cyclic residuals. The model also was not able to account for covid well but was pretty responsive afterwards. 
hist(ses_resid)

#This plot indicates that a majority of residuals occur between 1e-05 and 1e05 with the residuals being skewed towards the left tail, meaning there are more negative residuals ie: the model tends to over predict. 
fit_ses<-fitted.values(ses(Transit_ts))
ses_resid<-residuals(ses(Transit_ts))
plot(ses_resid)

ses_resid
##                Jan           Feb           Mar           Apr           May
## 2000   -7067.66664   30452.53069   92146.73071  -71285.46416   49194.29336
## 2001   34614.16470  -33450.43055   80048.69764  -29939.06089   42066.77886
## 2002   26455.00224  -33605.41828   58583.49079   14133.88642   15815.70332
## 2003   16801.87805  -43811.38056   80896.61617    3702.84266  -10116.77805
## 2004  -15183.12841    6966.65034   94144.04025  -24627.62625  -26209.38142
## 2005  -17134.47941   -8280.71297   90104.24357  -11344.64964  -12121.06816
## 2006   20864.68426  -27764.61495  107973.42583  -49964.44626   55374.89548
## 2007   25230.53170  -37530.56340  132079.11406  -29172.95166  104594.37713
## 2008   31730.21001  -11068.47042   52238.84901   26851.00824    8639.98724
## 2009  -12348.05617  -23081.25992   87819.11610   -9538.29761  -18632.28715
## 2010  -30940.70134  -47748.12568  140019.35285   -1140.56918  -17114.49959
## 2011  -24465.23459  -17266.97041  124644.73899  -30696.06160   18767.66198
## 2012   -1102.31972   16384.72121   56627.77400  -34693.18693   24794.57855
## 2013   31905.99626  -45931.88094   67886.74278   30039.94628    5712.62891
## 2014  -12337.27722  -21764.50686   97417.26984   23495.72441    6838.29147
## 2015  -46182.73894  -45545.05620  120255.65508   13740.10772  -27866.33996
## 2016  -56823.32412   27236.38310   79310.66374  -23402.09305    4987.93652
## 2017  -11348.56932  -26717.70564  104063.69279  -34628.31640   35440.12895
## 2018    3677.01227  -22042.97904   71508.97975    -379.94129   28787.20721
## 2019     -19.88805  -32937.23455   86388.16268   34607.97537   14045.56283
## 2020   17623.99339  -23549.67358 -286769.06564 -380849.47215  -32804.49666
## 2021  -17972.10049  -19952.94177   69313.89868   15314.05569   24168.64338
## 2022  -61534.08818   24765.23509   89308.76182    8763.97500   11825.35307
## 2023     -44.74156  -12937.27667   78516.91059  -20463.18727   45724.91351
##                Jun           Jul           Aug           Sep           Oct
## 2000  -16334.15141  -52821.54944   34727.22268   21099.95694   52170.64927
## 2001  -36537.35424  -28229.35265   20335.84194  -38120.62467   96757.14783
## 2002  -63661.76979     455.19377   -1165.96832   23217.36955   75869.02047
## 2003  -47331.36990    5415.13307  -20774.29501   57990.31565   33077.41376
## 2004    -837.63451  -30264.23098   13610.89393   43696.64500   38047.72350
## 2005  -13019.34311  -43279.43651   47053.13035   58430.61468    9356.02300
## 2006  -33686.95226  -42957.76971   43034.44551   17033.02487   59526.21264
## 2007  -99662.00710  -32776.80340   42534.25484    1884.67499   44032.51928
## 2008  -27081.81202   22165.47535  -16476.05723   35844.37132   48412.64747
## 2009  -11110.31303   -7455.95618  -19012.61985   46989.83052   50080.31974
## 2010  -13166.46350  -25663.36384   21653.16856   23319.62235   27606.65063
## 2011  -16098.66991  -39264.25126   12142.15099   50347.77197   35940.44775
## 2012  -44629.46583  -10039.43537   43098.20894   -9095.60479   45976.71141
## 2013  -55922.91096    7759.82426   21231.04026   15892.96836   74644.79642
## 2014  -48137.83574    3705.97128    1900.73079   44182.13056   62561.68177
## 2015    2406.88150   12069.44976  -47444.05199   48839.80670   63591.19569
## 2016  -11515.77329  -60308.89932   45587.49704   27044.24740    9260.41522
## 2017  -27248.09759  -56354.56896   37948.62038   13110.87778   68114.32350
## 2018  -30999.11374  -30244.62574   31070.08248  -11726.83207  103146.77456
## 2019  -58909.66143   12172.06592   15953.63727   12880.66348   71265.88197
## 2020   50274.75087   58681.57176   21451.83809   15899.87842   22903.92026
## 2021   39818.73349   19886.02874    8502.21873   36733.78162   42774.29915
## 2022    7345.24867  -25876.38537   33263.52322   35977.90417   25147.36495
## 2023  -28909.40350  -45329.75999                                          
##                Nov           Dec
## 2000  -26650.08361  -65414.30932
## 2001  -35616.63634  -69688.60917
## 2002  -76023.83413  -46853.34441
## 2003 -100420.36425   17565.85911
## 2004  -41794.00432  -36544.28232
## 2005  -32010.35758  -69340.09215
## 2006  -45838.79143  -54990.11735
## 2007  -68880.65067  -73462.59321
## 2008 -124777.27653  -23420.49400
## 2009  -79269.05008  -28251.13900
## 2010  -46253.11679  -32601.50229
## 2011  -50843.72688  -31778.10873
## 2012  -54449.45166  -47221.53565
## 2013  -97885.93916  -41006.94772
## 2014 -134687.10959     505.79316
## 2015  -94371.67178  -13049.39523
## 2016  -47603.90702  -40117.19176
## 2017  -68001.04050  -69067.53541
## 2018  -92144.44191  -64154.16360
## 2019  -89788.47816  -37352.99498
## 2020  -36454.95822   -7501.95194
## 2021  -24574.28474  -22676.70608
## 2022  -30023.08945  -33649.88735
## 2023
plot(fit_ses,ses_resid)

#In this plot, residuals remain rather constant across all fitted values. There are more residuals located as fitted values increase, but the residuals appear equally large in the lower fitted values. This could mean a few things, like that I have more data points at higher fitted values. 
plot(Transit_ts,ses_resid)

#This plot shows my residuals seem equally large regardless of the actual value. This chart alos suggests I have more larger actual values, leading to a cluster, IE: this data has a lot of lower outliers that skews the chert. 
acf(ses_resid)

#This plot shows many values outside of the blue lines. This means this model may have missed a pattern or signal or has some serious outliers. 
accuracy(ses(Transit_ts))
##                     ME     RMSE      MAE        MPE     MAPE      MASE
## Training set -812.0035 55127.84 40313.36 -0.8363806 6.026904 0.7092143
##                    ACF1
## Training set 0.01607982
#This model has a mape of 6.02. This is remarkably similar to my first mape with the naive model. This model did not drastically improve from the naive model. 
ses(Transit_ts,12)
##          Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## Aug 2023       539578.3 468678.2 610478.5 431145.9 648010.7
## Sep 2023       539578.3 447103.9 632052.8 398150.9 681005.8
## Oct 2023       539578.3 429686.5 649470.1 371513.3 707643.4
## Nov 2023       539578.3 414674.8 664481.9 348554.8 730601.9
## Dec 2023       539578.3 401283.0 677873.6 328073.9 751082.8
## Jan 2024       539578.3 389078.2 690078.4 309408.3 769748.4
## Feb 2024       539578.3 377791.5 701365.1 292146.7 787009.9
## Mar 2024       539578.3 367242.4 711914.2 276013.3 803143.4
## Apr 2024       539578.3 357302.8 721853.8 260812.0 818344.6
## May 2024       539578.3 347877.9 731278.7 246397.9 832758.8
## Jun 2024       539578.3 338895.2 740261.5 232659.9 846496.8
## Jul 2024       539578.3 330297.6 748859.1 219511.1 859645.6
plot(ses(Transit_ts,12))

#Overall, this model is still missing some signals as seen in the residual plot. This model also has a very similar mape to the naive model, not showing any improvements.
sse_holt<-HoltWinters(Transit_ts,beta = NULL,gamma = NULL)
plot(sse_holt)

#My alpha here is .928. This represent the weight given to recent data. My beta is 0. This represents how responsive the model is to trend.Gamma is 1, which represents how responsive the model is to seasonality. My initial level is 551045.439. My initial trend is 1531.450, and my initial seasonality is -9283.195. The initial values represent that values at the start. For example, initial trend shows average differences between actual values in the first season. Initial seasonality shows the deviation from the average in the first season.
resd_sse<-residuals(HoltWinters(Transit_ts,beta = NULL,gamma = NULL))
sd(resd_sse)
## [1] 43052.6
#sigma is 43052.5
plot(resd_sse)

#This plot shows the best residuals so far. This model did not account for covid well, however the residuals are not as cyclic as the past two models and smaller in values as well. 
fitt_sse<-fitted.values(sse_holt)
plot(fitted.values(sse_holt),resd_sse)

acf(resd_sse)

#This graph shows that the model has no trend and has little level until the impact from covid. The seasonality is consistent.I got an error when trying to plot my actual for vs residual values. It says incorrect number of dimensions. My acf plot of residuals shows most of the values are close to the blue lines, with a clear outlier at lag 0. This means that with the exception of lag one, the model is close to including all the signals needed to accurately predict. This iacf residual plot is the best for Holtwinters out of the plots done so far.   
forecast_holt<-forecast(sse_holt,h=12)
plot(forecast_holt)

accuracy(forecast_holt)
##                     ME     RMSE      MAE        MPE    MAPE      MASE
## Training set -2603.178 43051.87 26226.83 -0.8402477 4.26629 0.4613965
##                    ACF1
## Training set 0.06361874
#The mape here is 4.26. This is the most accurate model so far.
forecast_holt<-forecast(sse_holt,h=12)
plot(forecast_holt)
forecast_holt
##          Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## Aug 2023       543293.7 488119.6 598467.8 458912.1 627675.2
## Sep 2023       561299.7 486009.9 636589.4 446154.0 676445.4
## Oct 2023       607626.4 516561.0 698691.8 468353.9 746898.9
## Nov 2023       543024.6 438538.8 647510.3 383227.4 702821.7
## Dec 2023       519463.8 403095.3 635832.2 341493.5 697434.0
## Jan 2024       523711.3 396565.8 650856.8 329259.0 718163.6
## Feb 2024       518539.3 381461.4 655617.2 308896.8 728181.8
## Mar 2024       586939.7 440602.1 733277.4 363135.6 810743.8
## Apr 2024       562162.1 407116.7 717207.4 325040.6 799283.5
## May 2024       592045.8 428756.4 755335.2 342316.2 841775.3
## Jun 2024       572859.6 401722.8 743996.3 311128.5 834590.6
## Jul 2024       550583.4 371943.7 729223.1 277377.6 823789.2
#Overall, this model was the most accurate using the mape as a measure of accuracy. This model has a mape of 4.2. The predicted value in one year is 550583 in July. This is one of the only models that does not produce a flat forecast due to the use of trend and seasonality. 
Accuaracy_Comparison<-list("Naive Mape=6.06","SES Mape=6.02","Holtwinters Mape=4.02")
table(Accuaracy_Comparison)
## , , Accuaracy_Comparison.3 = Holtwinters Mape=4.02
## 
##                       Accuaracy_Comparison.2
## Accuaracy_Comparison.1 SES Mape=6.02
##        Naive Mape=6.06             1
#Looking at my accuracy comparison table, the Holtwinters model has the best Mape. I choose the mape at the accuracy measure of comparison because I find that postive vs negative error does not indciate much since over vs under forecasting is equally bad in this case. I find that mean absolute percent error is holistic as it creates a comparison to the original value. For example, saying you under forecasted by 20 units does not really tell me much on its own. However, if you come to learn that the absolute percent error for this forecast is 80%, suddenly this context highlights the stuggle in my model. 
plot(Transit_ts)

#Overall, the transit data shows a large amount of seasonality due to the cyclic patterns. This makes Holtwinters model the best, with the lowest mape of 4.02. In addition, this data also has trend following 2020, which the Holtwinters model is able to account for unlike the naive model. The projected value one year from now using the Holtwinters model is 550583. I think the use of trend after covid would suggest that this number will continue to increase over the next two years until it was fully recouped from covid. 

R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.